#pragma once
#include "Utility/Algebra/Matrix.h"
#include "DataStructure/Common/DataStructureNamespace.h"
#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Real.h"
#include "DataStructure/Input/Property/PropertyBase.h"

SG_DATASTRUCTURE_FEM_NAMESPACE_OPEN
/** @brief 梁截面属性
 *
 * 直接给定截面属性值,基于剖分截面的属性
 */
struct BeamMeshedSectionProperty : public PropertyBase
{
    SG::DataStructure::Common::Id   m_mid;              ///< 材料属性Id
    SG::DataStructure::Common::Real m_area;             ///< 截面积
    SG::DataStructure::Common::Real m_Iy, m_Iz, m_Iyz;  ///< 惯性矩
    SG::DataStructure::Common::Real m_J;                ///< 扭转常数
    SG::DataStructure::Common::Real m_yS, m_zS;         ///< 剪切中心
    SG::DataStructure::Common::Real m_yC, m_zC;         ///< 形心坐标
    SG::DataStructure::Common::Real m_alpha_y;
    SG::DataStructure::Common::Real m_alpha_z;
    SG::DataStructure::Common::Real m_alpha_yz;         ///< 剪切系数
    SG::DataStructure::Common::Real m_NSM;              ///< 非结构质量

    // 利用alpha求K，K={Ky 对应NASTRAN中 K2, Kyz; Kyz, Kz 对应NASTRAN中 K1}                                                    
    inline SG::Algebra::Matrixd ComputeK()
    {
        SG::Algebra::Matrixd alphaMat{2, 2, {m_alpha_y, m_alpha_yz, m_alpha_yz, m_alpha_z}};
        return  SG::Algebra::inverse2X2(alphaMat);
    }
};

SG_DATASTRUCTURE_FEM_NAMESPACE_CLOSE